// =====================================================================
// <copyright file="EnumerableExtensionsTest.cs" author="David R. Guindo">
// 	Copyright (C) 2013. All rights reserved.
// </copyright>
// =====================================================================
// This code is released under the terms of the Apache 2.0 license, 
// http://apache.org/licenses/LICENSE-2.0.html
// =====================================================================

namespace AppBlock.Core.Test.Extensions
{
    using System.Collections;
    using System.Diagnostics.CodeAnalysis;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    [TestClass]
    public class EnumerableExtensionsTest
    {
        [TestMethod]
        public void Count_Ok_Test()
        {
            IEnumerable items = new object[] {"1", "2", "3"};
#pragma warning disable 0618
            Assert.AreEqual(items.Count(), 3);
#pragma warning restore 0618
        }

        [TestMethod]
        [SuppressMessage("Microsoft.Design", "CA1011")]
        public void Count_Null_Test()
        {
#pragma warning disable 0618
            Assert.AreEqual((null as IEnumerable).Count(), 0);
#pragma warning restore 0618
        }

        [TestMethod]
        public void LongCount_Ok_Test()
        {
            object items = new object[] {"1", "2", "3"};
            var target = (items as IEnumerable).LongCount();
            Assert.AreEqual(target, 3);
            Assert.IsInstanceOfType(target, typeof (long));
        }

        [TestMethod]
        public void LongCount_Null_Test()
        {
            Assert.AreEqual((null as IEnumerable).LongCount(), 0);
        }
    }
}